<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>N6_1F储位管理 - 自动</title>
  <%@include file="/WEB-INF/common/css.jsp"%>
  <style>
  	#listshow thead tr th, #listshow tbody tr td{
  		text-align: center;
  	}
  	.selectstyle{
  		margin-top: 10px;
  	}
  </style>
  <%@include file="/WEB-INF/common/topjs.jsp"%>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  
  <%@include file="/WEB-INF/common/jsp/header.jsp"%>
  
  <div class="layui-body" style="left: 10px;padding-right: 50px;padding-left: 50px">
    <!-- 内容主体区域 -->
    	<br><br>
    	<form class="layui-form" lay-filter="selectForm">
    		<div class="layui-form-item">
			    <div class="layui-input-inline selectstyle">
			      <select id="machine" name="machine" lay-filter="machine">
			      </select>
			    </div>
			    <div class="layui-input-inline selectstyle">
			      <select id="item" name="item" lay-filter="item">
			      </select>
			    </div>
			    <div class="layui-input-inline selectstyle">
			      <select id="gjehState" name="gjehState" lay-filter="gjehState">
			      </select>
			    </div>
			    <div class="layui-input-inline selectstyle">
			      <select id="tempputState" name="tempputState" lay-filter="tempputState">
			      </select>
			    </div>
			  
			    <div class="layui-input-inline selectstyle">
			      <select id="liaohao" name="liaohao" lay-filter="liaohao">
			      </select>
			    </div>
			</div>
    	</form>
    	<hr>
		<table class="layui-table" id="listshow" border="1" style="background: #92CDDC">
			<thead>
				<tr class=""  style="background: #399ddb;color: #fff">
					<th>料号</th>
					<th>钢架编号</th>
					<th>大储位</th>
					<th>小储位</th>
					<th>箱号</th>
					<th>SN</th>
					<th>InputTime</th>
				</tr>
			</thead>
			<tbody>

			</tbody>
		</table>
  </div>
  
  <%@include file="/WEB-INF/common/jsp/footer.jsp"%>
  
</div>
<%@include file="/WEB-INF/common/bottomjs.jsp"%>
<script>

$(function(){
	findMachines();
	findItems();
	findGjehStates();
	findTempputStates();
	findLiaohao();
})
function bindEvent(filter){
	layui.form.on("select("+filter+")", function(data){
		if(filter == 'machine'){
			findItems();
		}else if(filter == 'item'){
			findGjehStates();
		}else if(filter == 'gjehState'){
			findTempputStates();
		}else if(filter == 'tempputState'){
			findLiaohao();
		}else if(filter == 'liaohao'){
			showData();
		}
	})
}
function showData(){
	$("#listshow tbody").html("");
	var hqlhHtml = "<img src='${base}/assets/image/alertemoj/hkl.gif' width='300px'/><br>";
	hqlhHtml += "<h4 style='text-align: center;font-size: 23px;margin-top: 27px;color:#149e5e;font-weight: bold'>不急，不急，数据正在火速从网线中爬过来</h4>";
	
	var hqlhAreat = layer.open({
		title : '感觉自己萌萌哒',
		content : hqlhHtml,
		btn:[],
		closeBtn: 0
	});
	$.ajax({
		url:"${base}/api/dataSummary/xjxc.api",
    	type: "post",
    	headers: Apicheck.getHeaders(),
    	data:{machine:$("#machine").find("option:selected").text()
    		, item:$("#item").find("option:selected").text()
    		, gjehState:$("#gjehState").find("option:selected").text()
    		, tempputState: $("#tempputState").find("option:selected").text()
			, liaohao: $("#liaohao").find("option:selected").text()},
    	success: function(result){
    		layer.close(hqlhAreat);
    		var xtable = new XTable();
    		xtable.setOption({
    			type: XTable.LEFT_CASCADE,
    			data: [result.data]
    		});
    		xtable.show("listshow");
    	}
	});
}

function findMachines() {
	$.ajax({
		url : "${base}/api/dataSummary/findMachinesByAuto.api",
		type : "post",
		headers: Apicheck.getHeaders(),
		success : function(result) {
			$("#machine").html("");
			$("#machine").append("<option value=''></option>");
			var list = result.data;
			for (var i = 0; i < list.length; i++) {
				$("#machine").append(
						"<option value='"+list[i].id+"'>"
								+ list[i].name + "</option>");
			}
			layui.form.render("select", "selectForm");
			bindEvent("machine");
		}
	});
}
function findItems() {
	$.ajax({
		url : "${base}/api/dataSummary/findItemsByAuto.api",
		type : "post",
		headers: Apicheck.getHeaders(),
		data:{machine: $("#machine").val()},
		success : function(result) {
			$("#item").html("");
			$("#item").append("<option value=''></option>");
			var list = result.data;
			for (var i = 0; i < list.length; i++) {
				$("#item").append(
						"<option value='"+list[i].id+"'>"
								+ list[i].name + "</option>");
			}
			layui.form.render("select", "selectForm");
			bindEvent("item");
		}
	});
}
function findGjehStates() {
	$.ajax({
		url : "${base}/api/dataSummary/findGjehStatesByAuto.api",
		type : "post",
		headers: Apicheck.getHeaders(),
		data: {machine: $("#machine").val(), item: $("#item").val()},
		success : function(result) {
			$("#gjehState").html("");
			$("#gjehState").append("<option value=''></option>");
			var list = result.data;
			for (var i = 0; i < list.length; i++) {
				$("#gjehState").append(
						"<option value='"+list[i].id+"'>"
								+ list[i].name + "</option>");
			}
			layui.form.render("select", "selectForm");
			bindEvent("gjehState");
		}
	});
}
function findTempputStates() {
	$.ajax({
		url : "${base}/api/dataSummary/findTempputStatesByAuto.api",
		type : "post",
		headers: Apicheck.getHeaders(),
		data: {machine: $("#machine").val(), item: $("#item").val(), gjehState:$("#gjehState").val()},
		success : function(result) {
			$("#tempputState").html("");
			$("#tempputState").append("<option value=''></option>");
			var list = result.data;
			for (var i = 0; i < list.length; i++) {
				$("#tempputState").append(
						"<option value='"+list[i].id+"'>"
								+ list[i].name + "</option>");
			}
			layui.form.render("select", "selectForm");
			bindEvent("tempputState");
		}
	});
}


function findLiaohao() {
	$.ajax({
		url : "${base}/api/dataSummary/findLiaohaosByAuto.api",
		type : "post",
		headers: Apicheck.getHeaders(),
		data: {machine: $("#machine").val(), item: $("#item").val(), gjehState:$("#gjehState").val(),tempputState:$("#tempputState").val()},
		success : function(result) {
			$("#liaohao").html("");
			$("#liaohao").append("<option value=''></option>");
			var list = result.data;
			for (var i = 0; i < list.length; i++) {
				$("#liaohao").append(
						"<option value='"+list[i]+"'>"
								+ list[i] + "</option>");
			}
			layui.form.render("select", "selectForm");
			bindEvent("liaohao");
		}
	});
}
</script>
</body>
</html>